package com.infitecs.eyas.util;

import java.text.DecimalFormat;

/**
 * Created by panzhuowen on 2015/4/30.
 */
public class DoubleUtil {

    public DoubleUtil() {
    }

    private static DoubleUtil instance;

    public static DoubleUtil getInstance() {
        if (instance == null) {
            instance = new DoubleUtil();
            return instance;
        }
        return instance;
    }

    public double get2Double(double result) {
        DecimalFormat decimalFormat = new DecimalFormat("#######0.00");
        return Double.parseDouble(decimalFormat.format(result));
    }

    public double get3Double(double result) {
        DecimalFormat decimalFormat = new DecimalFormat("#######0.000");
        return Double.parseDouble(decimalFormat.format(result));
    }

    public double get4Double(double result) {
        DecimalFormat decimalFormat = new DecimalFormat("#######0.0000");
        return Double.parseDouble(decimalFormat.format(result));
    }

    public double get6Double(double result) {
        DecimalFormat decimalFormat = new DecimalFormat("#######0.000000");
        return Double.parseDouble(decimalFormat.format(result));
    }

    public double get8Double(double result) {
        DecimalFormat decimalFormat = new DecimalFormat("#######0.00000000");
        return Double.parseDouble(decimalFormat.format(result));
    }


}
